Stop Condition
First-class loop stop conditions (invariant I-7). The SDK manages the loop; consumers express completion as a StopCondition passed to the agent constructor or generateText.
Built-ins:
stepCountIs — stop after N completed steps. Default
stepCountIs(20)so any agent without explicitstopWhenstill terminates.hasToolCall — stop the moment a specific tool is called.
anyOf — short-circuit OR over multiple conditions (matches v6's array form).
Custom: implement StopCondition directly. Receives a snapshot of the loop state on every check.